<template>

  <div class="app-container">
    <el-form :model="queryParams" color="blue" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
      <el-col :span="24">
        <el-form-item label="检查项目" prop="projectName">
          <el-radio-group v-model="queryParams.projectName" style="margin-bottom: 30px;">
            <el-radio-button>全选</el-radio-button>
              <span v-for="t in termList">
                <el-radio-button :label="t.projectName" >{{t.projectName}}</el-radio-button>
                </span>
          </el-radio-group>
        </el-form-item>
      </el-col>
      <el-col :span="24">
      <el-form-item label="检查单号" prop="registerNumber" >
        <el-input
          v-model="queryParams.registerNumber"
          placeholder="请输入检查单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">查询</el-button>
      </el-form-item>
      </el-col>
    </el-form>


    <el-table v-loading="loading" :data="inspectList" @selection-change="handleSelectionChange">
      <el-table-column
        label="检查单号"
        align="center"
        prop="registerNumber"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="患者姓名"
        align="center"
        prop="patientName"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="检查项目"
        align="center"
        prop="projectName"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="检查备注"
        align="center"
        prop="status"
        :show-overflow-tooltip="true"
      />
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
    import {queryNeedCheck, queryCheckName } from "@/api/docter/checkResult";
    export default {
        name: "Notice",
        data() {
            return {
                num: 0,
                // 遮罩层
                loading: false,
                // 选中数组
                ids: [],
                // 非单个禁用
                single: true,
                // 非多个禁用
                multiple: true,
                // 显示搜索条件
                showSearch: true,
                // 总条数
                total: 0,
                // 公告表格数据
                inspectList: [],
                // 弹出层标题
                termList:[],
                title: "",
                // 是否显示弹出层
                open: false,
                // 查询参数
                queryParams: {
                    pageNum: 1,
                    pageSize: 10,
                    registerNumber:undefined,
                    projectName:undefined
                },
                // 表单参数
                form: {},
                // 表单校验

            };
        },
        created() {
            this.getList2();
        },
        methods: {
            /** 查询公告列表 */
            getList() {
                this.loading = true;
                queryNeedCheck(this.queryParams).then(response => {
                    this.inspectList = response.rows;
                    console.log(response.rows)
                    this.total = response.total;
                    this.loading = false;
                });
            },
            getList2() {
                this.loading = true;
                queryCheckName(this.queryParams).then(response => {
                    this.termList = response.rows;
                    console.log(response.rows)
                    //this.total = response.total;
                    this.loading = false;
                });
            },
            // 取消按钮
            /*cancel() {
                this.open = false;
                this.reset();
            },
            // 表单重置
            reset() {
                this.form = {
                    drugName:undefined,
                    drugPrice:"0.00",
                    drugCode:undefined,
                    drugNumMin:"0.00",
                    drugConvert:undefined,
                    status: "0"
                };
                this.resetForm("form");
            },*/
            /** 搜索按钮操作 */
            handleQuery() {
                this.queryParams.pageNum = 1;
                this.getList();
            },
            /** 重置按钮操作 */
            /*resetQuery() {
                this.resetForm("queryForm");
                this.handleQuery();
            },*/
            // 多选框选中数据
            /*handleSelectionChange(selection) {
                this.ids = selection.map(item => item.regId)
                this.single = selection.length != 1
                this.multiple = !selection.length
            },*/
            /** 新增按钮操作 */
           /* handleAdd() {
                this.reset();
                this.open = true;
                this.title = "添加药品信息";
            },*/
            /** 修改按钮操作 */
            /*handleUpdate(row) {
                this.reset();
                const drugId = row.drugId || this.ids
                getDrug(drugId).then(response => {
                    this.form = response.data;
                    this.open = true;
                    this.title = "修改药品信息";
                });
            },*/
           /* /!** 提交按钮 *!/
            submitForm: function () {
                this.$refs["form"].validate(valid => {
                    if (valid) {
                        if (this.form.drugId != undefined) {
                            updateDrug(this.form).then(response => {
                                this.$modal.msgSuccess("修改成功");
                                this.open = false;
                                this.getList();
                            });
                        } else {
                            addDrug(this.form).then(response => {
                                this.$modal.msgSuccess("新增成功");
                                this.open = false;
                                this.getList();
                                this.getList2();
                            });
                        }
                    }
                });
            },*/
            handleUpdate(row) {
                const registerNumber = row.registerNumber || this.ids
                this.$modal.confirm('是否开始检查单号为"' + registerNumber + '"的检查项目？').then(function () {
                    return updateIns(registerNumber);
                }).then(() => {
                    this.getList();
                    //this.getList2();
                    this.$modal.msgSuccess("修改成功");
                }).catch(() => {
                });
            }
        }
    };
</script>
